package Month07.day27.test2;

import java.util.Comparator;
import java.util.TreeSet;

public class main {
    public static void main(String[] args) {
        TreeSet<Teacher> teachers = new TreeSet<>(new Comparator<Teacher>() {
            @Override
            public int compare(Teacher o1, Teacher o2) {
                int result=o1.getAge()-o2.getAge();
                result=result==0?o1.getName().compareTo(o2.getName()):result;
                return result;
            }
        });
        Teacher teacher = new Teacher("zhangsan",17);
        Teacher teacher1 = new Teacher("lisi",10);
        Teacher teacher2 = new Teacher("wangwu",12);
        teachers.add(teacher1);
        teachers.add(teacher);
        teachers.add(teacher2);
        System.out.println(teachers);
    }
}
